package com.apes.fn.scm.settleCheck.model;


import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.finance.model.IncomeType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 功能：赋能商户结算政策明细
 *
 * @author zhuyh
 * @time 14:40
 * @date 2020/2/28
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = PartnerCheckItem.CONST_TABLE_NAME)
public class PartnerCheckItem extends Model {

    public static final String CONST_TABLE_NAME = "fn_partner_check_item";

    @Id
    @Column(name = "id", length = 24, nullable = false)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "赋能结算政策明细", padding = 12)
    private String id;


    @ManyToOne(optional = false)
    @JoinColumn(name = "partner_check_id", referencedColumnName = "id")
    @Comment("决策单号")
    private PartnerCheck partnerCheck;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "expense_type_id", referencedColumnName = "id")
    @Comment("费用类型")
    private IncomeType expenseType;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "cost_Type", referencedColumnName = "id")
    @Comment("计算基数")
    private Enumeration costType; //(销售金额;采购金额;保险佣金;门店数);

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "cacl_type", referencedColumnName = "id")
    @Comment("计算周期")
    private Enumeration caclType; //(单次;每月;每季度;每半年;每年);

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "lastcheck_date")
    @Comment("上次结算日期")
    private Date lastCheckDate; //上次结算日期


    @Column(name = "rateOne", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("费率1")
    private double rateOne = 0.0;  //费率1

    @Column(name = "scaleOne", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("规模1")
    private double scaleOne;//规模1

    @Column(name = "rateTwo", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("费率2")
    private double rateTwo = 0.0;  //费率2

    @Column(name = "scaleTwo", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("规模2")
    private double scaleTwo;//规模2

    @Column(name = "rateThree", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("费率3")
    private double rateThree = 0.0;  //费率3

    @Column(name = "scaleThree", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("规模3")
    private double scaleThree;//规模3


    @Column(name = "rateFour", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("费率4")
    private double rateFour = 0.0;  //费率4

    @Column(name = "scaleFour", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("规模4")
    private double scaleFour;//规模4

    @Column(name = "rateFive", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("费率5")
    private double rateFive = 0.0;  //费率5

    @Column(name = "scaleFive", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("规模5")
    private double scaleFive;//规模5

    @Column(name = "rateSix", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("费率6")
    private double rateSix = 0.0;  //费率6

    @Column(name = "scaleSix", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("规模6")
    private double scaleSix;//规模6

    @Column(name = "guaranteeAmount", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("保底金额")
    private double guaranteeAmount = 0.0;  //

    @Column(name = "accoutOfCapping", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("封顶金额")
    private double accoutOfCapping;//

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "period_start")
    @Comment("费用期起")
    private Date periodStart;

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "period_end")
    @Comment("费用期止")
    private Date periodEnd;

}
